package com.leo;

import com.jfoenix.controls.JFXDialog;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;

import java.net.URL;

/**
 * @ClassName JFXDialogDemo
 * @Description
 * @Author wangss
 * @date 2020.11.26 14:32
 * @Version 1.0
 */
public class JFXDialogDemo extends Application {

    public static void main(String[] args) {
        launch(args);
    }

    @Override
    public void start(Stage primaryStage) throws Exception {
        final StackPane stackPane = new StackPane();
        stackPane.getChildren().add(new Label("123"));
        Button button = new Button("对话框");

        JFXDialog dialog = new JFXDialog();
        dialog.setContent(new Label("Content"));
        button.setOnAction((action) -> dialog.show(stackPane));

        AnchorPane an = new AnchorPane();
        an.getChildren().addAll(button);

        Scene scene = new Scene(an);
        URL url = this.getClass().getResource("/css/myStyle.css");
        scene.getStylesheets().add(url.toExternalForm());
        primaryStage.setScene(scene);
        primaryStage.setWidth(800);
        primaryStage.setHeight(650);
        primaryStage.setTitle("JFoeniX测试");
        primaryStage.show();
    }
}
